import os

from langchain_community.embeddings import DashScopeEmbeddings

from pydantic import  ConfigDict

model_config=ConfigDict(
        extra="forbid",
    )
# model_config['dimensions'] = 1024

embeddings = DashScopeEmbeddings(model="text-embedding-v3", dashscope_api_key=os.getenv('ALIYUN-API-KEY'))
text = "This is a test document."
query_result = embeddings.embed_query(text)
#不支持设置维度
print(f"嵌入维度: {len(query_result)}")
print(query_result[:4])
